﻿#ifndef __INC_QG_WIDGET_SORT_H__
#define __INC_QG_WIDGET_SORT_H__

namespace _widget
{
	// 소트 클래스
	struct SortWidget
	{
		bool operator()(qwControl* l, qwControl* r)
		{
			if (l->GetWidgetType() == QGW_FORM)
			{
				if (r->GetWidgetType() != QGW_FORM)
					return true;
				else
					return l->GetDepth() > r->GetDepth();
			}
			else
			{
				if (r->GetWidgetType() == QGW_FORM)
					return false;
				else
					return l->GetDepth() > r->GetDepth();
			}
		}

		// k_qsort용 콜백
		static kint Callback(kconstpointer p1, kconstpointer p2)
		{
			qwControl* w1 = *(qwControl**)p1;
			qwControl* w2 = *(qwControl**)p2;

			if (w1->GetDepth() > w2->GetDepth())
				return -1;
			else if (w1->GetDepth() < w2->GetDepth())
				return 1;
			else
				return 0;
		}
	};
}

#endif	// __INC_QG_WIDGET_SORT_H__
